<template>
  <div class="pad-out-box new-table-style relative-box">
    <option-list ref="option"></option-list>
    <el-table :border="false" stripe :data="tableData">
      <!-- <el-table-column align="left" label="序号" prop="kjine">
        <template slot-scope="scope">
          <span>{{ scope.$index + 1 }}</span>
        </template>
      </el-table-column> -->
      <el-table-column align="left" label="会议主题" prop="meetingContent"></el-table-column>
      <el-table-column align="left" label="会议时间">
        <template slot-scope="scope">
          <span>{{ scope.row.meetingTime | formatDateTime('YYYY-MM-DD HH:mm') }}</span>
        </template>
      </el-table-column>

      <el-table-column align="left" label="操作" width="80">
        <template slot-scope="scope">
          <el-button type="text" @click="addMeeting(scope.row.primaryKey)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <Pagination v-if="total > tableData.length" @change="pageChange" :total="total" paginationLayout="total, prev, pager, next" />
  </div>
</template>
<script>
  import { apiMeetingList } from '../../api/workTrace';
  import optionList from './components/optionList';
  import workTrace from '../../mixin/workTrace';

  export default {
    mixins: [workTrace],

    data() {
      return {
        tableData: [],
        total: 0,
        currentPage: 1,
        pageSize: 10,
      };
    },

    mounted() {
      this.getDataSource();
    },

    methods: {
      async getDataSource(more) {
        let res = await apiMeetingList({
          currentPage: more ? this.currentPage : 1,
          pageSize: this.pageSize,
        });
        this.tableData = res.rows || [];
        this.total = res.total || 0;
      },

      //新建工作
      addMeeting(key) {
        let params = {
          name: 'trace-summary-info',
          query: {
            spaceKey: this.$route.query.spaceKey,
            headerName: '会议纪要',
          },
        };

        if (key) {
          params.query.meetingKey = key;
        }

        let router = this.$router.resolve(params);
        window.open(router.href, '_blank');
      },

      //分页
      pageChange(page) {
        this.currentPage = page.currentPage;
        this.getDataSource('more');
      },
    },

    components: { optionList },
  };
</script>
<style lang="scss" scoped></style>
